#include "thread/Thread.h"

#include <iostream>

class Foo {
public:
    Foo(int count) : _count{count} {}
    
    void bar() {
        while (_count--)
        {
            std::cout << "This is bar\n";
        }
    }

    void bar2(int count) {
        while (_count--) {
            std::cout << "This is bar2\n";
        }
    }

private:
    int _count;
};

void func() {
    std::cout << "func ...\n";
}

void func2(int count) {
    while (count > 0)
    {
        std::cout << "func2 ... " << count << std::endl;
        count--;
    }
}

int main() {
    Foo foo1{3};
    Foo foo2{3};

    Thread t1([](){ func(); }, "t1");
    Thread t2([](){ func2(3); }, "t2");
    Thread t3([&foo1](){ foo1.bar(); }, "t3");
    Thread t4([&foo2](){ foo2.bar2(4); }, "t4");

    t1.start();
    t2.start();
    t3.start();
    t4.start();

    t1.join();
    t2.join();
    t3.join();
    t4.join();
}